
package com.newland.starpos.partner.http;

/**
 * 异常码
 * @author fangxu.ge
 * 
 */
public enum ExceptionCodeEnum {

    /** common 异常码 **/

    PARAM_NULL("PARAM_NULL", "输入参数为空"),
    
    DATA_FOUNT_REAL_NAME("DATA_FOUNT_REAL_NAME", "该用户信息已认证"),
    
    DATA_NOT_FOUNT_REAL_NAME("DATA_NOT_FOUNT_REAL_NAME", "未查到该用户认证信息,请先进行实名认证"),
    
    DATA_FOUNT_BANK_CARD("DATA_FOUNT_BANK_CARD", "该行银行卡信息已绑定"),
    
    DATA_NOT_FOUNT_BANK_CARD("DATA_NOT_FOUNT_BANK_CARD", "未查到该银行卡信息,请先进行银行卡信息绑定"),
    
    ERROR_ID_CARD("ERROR_ID_CARD", "请检查你输入的身份证位数是否正确"),
    
    USER_INFORMATION_ISNULL("USER_INFORMATION_ISNULL","未查询到该用户信息"),
    
    DECODE_FAILED("DECODE_FAILED", "解码失败"),
	
	SAVE_DATA_FAILED("SAVE_DATA_FAILED", "保存数据失败"),
	
	UPDATE_DATA_FAILED("UPDATE_DATA_FAILED", "更新数据失败"),
	
	UPDATE_NEW_PASSWORD_FAILD("UPDATE_NEW_PASSWORD_FAILD","更新密码失败"),
	
	DELETE_DATA_FAILED("DELETE_DATA_FAILED", "删除数据失败"),
	
	ERROR_LOG_PWDISNULL("ERROR_LOG_PWDISNULL", "原始密码不能为空"),
	
	ERROR_NEW_PWDISNULL("ERROR_NEW_PWDISNULL", "新密码不能为空"),
	
	ERROR_PAYMENT_PWDISNULL("ERROR_PAYMENT_PWDISNULL","原始支付密码不能为空"),

	ERROR_CONFIRME_NEW_PWDISNULL("ERROR_CONFIRME_NEW_PWDISNULL","确认新密码不能为空"),
	
	ENCRYPTION_FAIL("ENCRYPTION_FAIL","加密失败"),
	
	ERROR_PWDISNULL("ERROR_PWDISNULL", "两次输入的密码不一致，请重新输入"),
	
	REQUEST_PARAM_DATA_ISNULL("REQUEST_PARAM_DATA_ISNULL", "输入参数DATA对象为空"),
	
	USER_NULL("USER_NULL","无此用户"),
	
	OK("OK","成功");
	
	
    /**
     * 根据编码找枚举
     * 
     * @param code 编码
     * @return
     */
    public static ExceptionCodeEnum getByCode(String code) {
        if (code == null) {
            return null;
        }

        for (ExceptionCodeEnum t : values()) {
            if (t.getCode().equals(code)) {
                return t;
            }
        }
        return null;
    }

    private final String code;

    private final String label;

    private ExceptionCodeEnum(String code, String label) {
        this.code = code;
        this.label = label;
    }

    public String getCode() {
        return code;
    }

    public String getLabel() {
        return label;
    }

    public ExceptionCodeEnum returnEnum(String persistedValue) {
        return getByCode(persistedValue);
    }

}